package interfaz;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;

public class JButtonImagen extends JButton{

	private static final long serialVersionUID = 1L;
	private String rutaImagen;

	public JButtonImagen(String rutaImagen){
		this.rutaImagen = rutaImagen;
		setOpaque(false);
	}
	
	@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g;
        try {
			g2d.setPaint(new TexturePaint(ImageIO.read(new File(rutaImagen)), new Rectangle(0, 0, getWidth(),getHeight())));
			g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
        } catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
}
